package vcp.gui.components;

import java.awt.event.WindowEvent;

import javax.swing.JPanel;

public class VCPFrame extends VCPFrameAbstract {
     public VCPFrame(){
    	 super();
 		 initialize();
     }
     
     private void initialize(){
 		this.addWindowListener(new java.awt.event.WindowAdapter() {
 			 public void windowClosing(WindowEvent e) {
 				 vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowClosing.");
 			        //A pause so user can see the message before
 			        //the window actually closes.
 			        /*
 			        ActionListener task = new ActionListener() {
 			            boolean alreadyDisposed = false;
 			            public void actionPerformed(ActionEvent e) {
 			                if (frame.isDisplayable()) {
 			                    alreadyDisposed = true;
 			                    frame.dispose();
 			                }
 			            }
 			        };
 			        Timer timer = new Timer(500, task); //fire every half second
 			        timer.setInitialDelay(2000);        //first delay 2 seconds
 			        timer.setRepeats(false);
 			        timer.start();
 			        */
 			    }

 			    public void windowClosed(WindowEvent e) {
 			        //This will only be seen on standard output.
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowClosed.");
 			    }

 			    public void windowOpened(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowOpened.");
 			    }

 			    public void windowIconified(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowIconified.");
 			    }

 			    public void windowDeiconified(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowDeiconified.");
 			    }

 			    public void windowActivated(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowActivated.");
 			    }

 			    public void windowDeactivated(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowListener method called: windowDeactivated.");
 			    }

 			    public void windowGainedFocus(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowFocusListener method called: windowGainedFocus.");
 			    }

 			    public void windowLostFocus(WindowEvent e) {
 			    	//vcp.gui.utils.DebugUtils.displayMessage("WindowFocusListener method called: windowLostFocus.");
 			    }
                 
 			    /*
 			    public void windowStateChanged(WindowEvent e) {
 			    	displayMessage("WindowStateListener method called: windowStateChanged.", e);
 			    }
 			    */
 	    });
 	}
     public void changePanel(JPanel panel) {
 		if(panel!=null){
 		  this.setContentPane(panel);
 		  this.pack();
 		}		
 	}
 	
 	// temporary stupid public force kill // 
 	public void die(){
 		if(this.isActive()){
 		  setVisible(false);
 		  dispose();		  
 		}
 	}	
}
